package com.spancer.ribbonconfigure;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.spancer.contentcenter.configuration.NacosSameClusterWeightedRule;
import com.spancer.contentcenter.configuration.NacosWeightedRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * author by: mars
 * Date: 2020/8/15 14:01
 * Description: 定义Ribbon规则
 */
@Configuration
public class RibbonConfiguration {

    // 定义ribbon负载均衡规则
    @Bean
    public IRule ribbonRule(){
        return new RandomRule(); // -随机
        //return new NacosWeightedRule();-自定义nacos权重
        //return new NacosSameClusterWeightedRule(); // 自定义-nacos-集群权重
    }
}
